package org.thalien.roleplay.guice;

import java.util.ArrayList;
import java.util.List;

import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.persist.PersistService;
import com.google.inject.persist.jpa.JpaPersistModule;
import com.google.inject.servlet.GuiceServletContextListener;

public class MyGuiceServletConfig extends GuiceServletContextListener {

	@Override
	protected Injector getInjector() {
		List<Module> modules = new ArrayList<Module>();
		
		modules.add(new JpaPersistModule("roleplayPU"));
		modules.add(new MyServletModule());
		modules.add(new GsonModule());
		
		Injector injector = Guice.createInjector(modules);
		
		PersistService service = injector.getInstance(PersistService.class);
		service.start();
		
		return injector;
	}
}
